<style>
.modal_syskeyboard{}
.modal_syskeyboardbox{padding:10px;}
.modal_syskeyboardshowgood ul{ height:140px; margin-bottom:5px; width:100%; overflow:hidden;}
.modal_syskeyboardshowgood ul li{ display:inline-block; width:96px; border:1px solid #CCC; border-radius:4px; margin-right:4px;}
.modal_syskeyboardshowgood ul li img{ display:block; margin-bottom:5px; border-top-left-radius:4px;border-top-right-radius:4px;}
.modal_syskeyboardshowgood ul li h3{ text-align:center}
.modal_syskeyboardshowgood ul li p{ text-align:center}
.modal_syskeyboardinput{ position:relative;}
.modal_syskeyboardinput a{ position:absolute;left:10px;line-height:40px;font-size:18px;}
.modal_syskeyboardinput input{ border:1px solid #CCC;display:block;border-radius:4px; background:none; text-align:center; font-size:20px; width:100%; margin-bottom:5px; line-height:40px;}
.modal_syskeyboardbtns ul{}
.modal_syskeyboardbtns ul li{display:inline-block; width:54px; margin:5px;}
.modal_syskeyboardbtns ul li a{ display:block; border:1px solid #CCC; height:54px; line-height:54px; text-align:center; font-size:18px; font-weight:bold}
.modal_syskeyboardnum ul{ text-align:center;}
</style>
<div class="modal_syskeyboard" style="display:none">
  <div class="modal_syskeyboardbox">
  	<div class="modal_syskeyboardshowgood">
    	<ul>
        	
        </ul>
    </div>
    <div class="modal_syskeyboardinput"><a href="javascript:" onclick="$('#modal_syskeyboardtxt').val('');$('.modal_syskeyboardshowgood ul').empty();">清除</a><input type="text" id="modal_syskeyboardtxt" readonly /></div>
    <div class="modal_syskeyboardbtns">
    <div class="modal_syskeyboardword">
      <ul>
          <li><a href="javascript:">Q</a></li>
          <li><a href="javascript:">W</a></li>
          <li><a href="javascript:">E</a></li>
          <li><a href="javascript:">R</a></li>
          <li><a href="javascript:">T</a></li>
          <li><a href="javascript:">Y</a></li>
          <li><a href="javascript:">U</a></li>
          <li><a href="javascript:">I</a></li>
          <li><a href="javascript:">O</a></li>
          <li><a href="javascript:">P</a></li>
          <li><a href="javascript:">Del</a></li>
      </ul>
      <ul style="margin-left:27px;">
          <li><a href="javascript:" keycode="65">A</a></li>
          <li><a href="javascript:">S</a></li>
          <li><a href="javascript:">D</a></li>
          <li><a href="javascript:">F</a></li>
          <li><a href="javascript:">G</a></li>
          <li><a href="javascript:">H</a></li>
          <li><a href="javascript:">J</a></li>
          <li><a href="javascript:">K</a></li>
          <li><a href="javascript:">L</a></li>
          <li style="width:27px"></li>
          <li><a href="javascript:">Clear</a></li>
      </ul>
      <ul style="margin-left:54px;">
          <li><a href="javascript:">Z</a></li>
          <li><a href="javascript:">X</a></li>
          <li><a href="javascript:">C</a></li>
          <li><a href="javascript:">V</a></li>
          <li><a href="javascript:">B</a></li>
          <li><a href="javascript:">N</a></li>
          <li><a href="javascript:">M</a></li>
          <li></li>
          <li style="width:67PX"></li>
          <li><a href="javascript:">数字</a></li>
      </ul>
      
    </div>
    <div class="modal_syskeyboardnum" style="display:none;">
    	<ul>
          <li><a href="javascript:">7</a></li>
          <li><a href="javascript:">8</a></li>
          <li><a href="javascript:">9</a></li>
          <li><a href="javascript:">Del</a></li>
          </ul><ul>
          <li><a href="javascript:">4</a></li>
          <li><a href="javascript:">5</a></li>
          <li><a href="javascript:">6</a></li>
          <li><a href="javascript:">Clear</a></li>
          </ul><ul>
          <li><a href="javascript:">1</a></li>
          <li><a href="javascript:">2</a></li>
          <li><a href="javascript:">3</a></li>
          <li><a href="javascript:">字母</a></li>
          </ul><ul>
          <li style="width:257px;"><a href="javascript:">0</a></li>
      </ul>
    </div>
    </div>
  </div>
</div>

<script language="javascript">
function funSys_keyboard(){
	if(!$("#orderid").val()){
		layer.msg("请先开台",{icon:2,time:1000});
		return false;
	}
	layer.open({
		type: 1,
		title:"快速录入",
		area:"780px",
		skin: 'layui-layer-rim',
		shade:0,
		content:$(".modal_syskeyboard").show(),
		success: function(layero, index){
			$("#modal_syskeyboardtxt").val("");
			$(".modal_syskeyboardshowgood ul").empty();
			$(".modal_syskeyboardword").show();
			$(".modal_syskeyboardnum").hide();
			$(".modal_syskeyboardbtns a").bind("click",function(){
				var txt=$(this).text();
				var val=$("#modal_syskeyboardtxt").val();
				switch(txt){
					case "Del":
						var tempval=val.substring(0,val.length-1);
						$("#modal_syskeyboardtxt").val(tempval);
						funSys_keyboardsearch(tempval);
					break;
					case "Clear":
						$("#modal_syskeyboardtxt").val("");
						$(".modal_syskeyboardshowgood ul").empty();
					break;
					case "数字":
						$(".modal_syskeyboardword").hide();
							$(".modal_syskeyboardnum").show();
					break;
					case "字母":
						$(".modal_syskeyboardword").show();
						$(".modal_syskeyboardnum").hide();
					break;
					default:
						var keyword=val+txt;
						$("#modal_syskeyboardtxt").val(keyword);
						funSys_keyboardsearch(keyword);
					break;
				}
			});
			var keycode={65:"A",66:"B",67:"C",68:"D",69:"E",70:"F",71:"G",72:"H",73:"I",74:"J",75:"K",76:"L",77:"M",78:"N",79:"O",80:"P",81:"Q",82:"R",83:"S",84:"T",85:"U",86:"V",87:"W",88:"X",89:"Y",90:"Z",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9"};
			$(document).bind("keyup",function(event){
				if($(".modal_syskeyboardbox").is(":visible")){
					if(event.keyCode >= 65 && event.keyCode <= 90){
						var keystr=keycode[event.keyCode];
						$(".modal_syskeyboardbtns a:contains('"+keystr+"')").click();
					}else if(event.keyCode == 8){
						$(".modal_syskeyboardbtns a:contains('Del')").click();
						event.keyCode = 0; 
						return false;
					}else if(event.keyCode == 27){
						$(".modal_syskeyboardbtns a:contains('Clear')").click();
						event.keyCode = 0; 
						return false;
					}else if(event.keyCode >= 48 && event.keyCode <= 57){
						var keystr=keycode[event.keyCode];
						$(".modal_syskeyboardbtns a:contains('"+keystr+"')").click();
					}else if(event.keyCode >= 96 && event.keyCode <= 105){
						var keystr=keycode[event.keyCode];
						$(".modal_syskeyboardbtns a:contains('"+keystr+"')").click();
					}
				}
			});
		},
		end:function(){
			$(".modal_syskeyboard").hide();
			$(".modal_syskeyboardbtns a").unbind("click");
			$(document).unbind("keyup");
		}
	});
}
function funSys_keyboardsearch(keyword){
	var index2=layer.load(1);
	$.post("{php echo $this->createMobileUrl('index',array('op'=>'fastgood'))}",{keyword:keyword},function(returnstr){
		layer.close(index2);
		console.log(returnstr);
		var result=eval("("+returnstr+")");
		$(".modal_syskeyboardshowgood ul").empty();
		if(result.success){
			var goods=result.goods;
			if(!goods)return;
			for(var i=0; i<goods.length;i++){
				var temp='<li onclick="funSys_selectgood('+goods[i].id+')" gid="'+goods[i].id+'" title="'+goods[i].title+'" goodsn="'+goods[i].goodsn+'" store="'+goods[i].store+'" price="'+goods[i].marketprice+'" mprice="'+goods[i].memberprice+'" taste="'+goods[i].taste+'"><img src="'+goods[i].thumb+'" onerror="this.src=\'{MODULE_URL}template/resources/img/002.png\';" style="width:96px; height:96px;"/><h3>'+goods[i].title+'</h3><p>￥'+goods[i].marketprice+'</p></li>';
				$(".modal_syskeyboardshowgood ul").append(temp);
			}
		}
	});
}
function funSys_selectgood(gid){
	if(!$("#orderid").val()){
		layer.msg("请先开台",{icon:2,time:1000});
		return;
	}
    var taste=arguments.length>1 ? arguments[1] : "";
    if($(".modal_syskeyboardshowgood li[gid='"+gid+"']").attr("taste") && arguments.length==1){
        funSys_selectTaste(gid);
        return;
    }
	var oTarget=$(".modal_syskeyboardshowgood li[gid='"+gid+"']");
	var index=$(".listmenu li").size()+1;
	var price=oTarget.attr("price");
	var mprice=oTarget.attr("mprice");
	var title=oTarget.attr("title");
	var goodsn=oTarget.attr("goodsn");
	menuListSwiper.prependSlide('<li class="swiper-slide" isnew="true" gid="'+gid+'" goodsn="'+goodsn+'" title="'+title+'" price="'+price+'" mprice="'+mprice+'" oprice="'+price+'" onclick="fun_selectmenu(this)"><div class="til">'+title+'<div class="taste">'+taste+'</div><div class="extension"></div></div><div class="numinput"> <span class="txt_num">1</span> </div><div class="priceinput"> <span>￥'+price+'</span> <s></s></div></li>');

	$(".listmenu").css("overflow","visible");
	menuListSwiper.updateSlidesSize();
	menuListSwiper.slideTo(0);
    $(".modal_syskeyboardshowgood ul").empty();
    $("#modal_syskeyboardtxt").val('');
	fun_sumTotal();
}
function funSys_selectTaste(gid){
    layer.open({
        type: 1,
        title:"选择口味",
        area:'440px',
        skin: 'layui-layer-rim',
        content:$(".modal_taste").show(),
        btn:['确认','取消'],
        btn1:function(index,layero){
            var temp=[];
            $(".modal_taste .isselect").each(function(index, element) {
                temp.push($(this).text());
            });
            funSys_selectgood(gid,temp.join(','));
            layer.close(index);
        },
        success: function(layero, index){
            var tastestr=$(".modal_syskeyboardshowgood li[gid='"+gid+"']").attr("taste");
            var tasteary=tastestr.split("|");
            $(".modal_tastebox").empty();
            for(var i in tasteary){
                $(".modal_tastebox").append("<span>"+tasteary[i]+"</span>");
            }
            $(".modal_tastebox span").bind("click",function(){
                if($(this).hasClass("isselect")){
                    $(this).removeClass("isselect");
                }else{
                    $(this).addClass("isselect");
                }
            });
        },
        end:function(){
            $(".modal_taste").hide();
            $(".modal_tastebox span").unbind("click");
        }
    });
}
</script>